<?php

namespace app\admin\controller;

use think\Controller;
use think\Db;

class Auth extends Controller
{
    public function check($name,$uid)
    {
      //权限白名单
      $data = [
        'home/Index/index',
        'home/Index/newlist',
        'home/Index/register',
        'home/Index/pwdretrieve',
        'home/Index/pwdsendemail',
        'home/Article/detail',
        'home/Article/category',
        'home/Index/login',
        'home/Index/regsendemail'
      ];
     foreach ( $data as $item){
           if ($item == $name){
              return true;
           }
        }

        $userGroupId = Db::name("auth_group_user")->where("uid",$uid)->value("group_id");
        $groupRuleListId = Db::name("auth_group_rule")->where("group_id",$userGroupId)->column("rule_id");
      
        foreach ($groupRuleListId as $id){
            $ruleItem = Db::name("auth_rule")->where("id",$id)->value("name");
           if ($ruleItem == $name){
              return true;
           }
        }
    }

}